<template>
	<view>
		<text></text>
		<view style="margin: 30rpx;">
			<uni-section title="请添加开户证明" type="line">
				<view>
					<image mode="aspectFit" :src="ssrc" @click="tj()"></image>
				</view>
			</uni-section>
			<uni-section title="请添加门头照" type="line">
							<view>
								<image mode="aspectFit" :src="mtrc" @click="mtz()"></image>
							</view>
			</uni-section>
			<text>开户名称\n</text>
			<input type="text" :value="khms.customerName" class="bo"/>
			<text>开户省市\n</text>
			<input type="text" :value="khms.province" class="bo"/>
			<text>开户银行\n</text>
			<input type="text" :value="khms.bank" class="bo"/>
			<text>开户支行\n</text>
			<input type="text" :value="khms.ibank" class="bo"/>
			<text>银行账号\n</text>
			<input type="text" :value="khms.bankAccount" class="bo"/>
		</view>
		<view style="display: flex; flex-direction: row; margin: 15rpx;">
			<view class="flex.item"><button size="mini" @click="back()">取消</button></view>
			<view class="flex.item"></view>
			<view class="flex.item"><button size="mini" @click="examine()">确认</button></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ssrc:"../../static/iconfont/添加.png",
				mtrc:"../../static/iconfont/添加.png",
				khms:{
					approvalNumber: '',
					bankAccount: '',
					customerName: '',
					depositaryBank: '',
					legalRepresentative: '',
					permitNumber: '',
					title: '',
					province:'',
					bank:'',
					ibank:'',
					zid:''
				}
			}
		},
		
		created() {
			this.zid=this.$store.state.id;
			console.log(this.$store.state.id)
			const baseUrl="http://localhost:8888"
			uni.request({
				url:baseUrl+'/s/business/'+this.zid,
				method:"GET"
			}).then(res=>{
				console.log(res)
				})
		},
		methods: {
			back(){
				uni.navigateBack()
			},
			examine(){
				const baseUrl="http://localhost:8888";
					uni.request({
								url:baseUrl+'/s/business/add',
								method:"POST",
								data:this.khms
							}).then(res=>{
								
							})
			},
			tj(){
				var this_=this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function (res) {
						console.log(JSON.stringify(res.tempFilePaths));
						this_.ssrc=res.tempFilePaths
						this_.file=this_.ssrc
						const baseUrl="http://localhost:8888";
						uni.uploadFile({
							url: baseUrl+'/rz/rz',
							name: 'file',
							filePath:this_.file[0],
							header: {
								'Content-type':'multipart/form-data'
							},
							success: (uploadFileRes) => {
								
								var p =JSON.parse(uploadFileRes.data)
								this_.khms=p.data
								
								console.info(this_.khms.depositaryBank)
								var l = this_.khms.depositaryBank.split("")
								
								console.info(l)
								this_.khms.province=l[0]+l[1]+l[2]+l[3]
								this_.khms.bank=l[4]+l[5]+l[6]+l[7]+l[8]+l[9]
								this_.khms.ibank=l[10]+l[11]+l[12]+l[13]
								console.info(this_.khms.province)
								console.log(uploadFileRes, '上传成功')
								this_.khms.zid=this_.zid
								
								
								
								
								//获取阿里云路径
								uni.uploadFile({
									
									url: baseUrl+'/s/business/addzidcard/'+this_.zid,
									name: 'file',
									filePath:this_.file[0],
									header: {
										'Content-type':'multipart/form-data'
									},
									success: (uploadFileRes) => {
										// console.log(uploadFileRes)
										var a=JSON.parse(uploadFileRes.data)
										console.log(a)
									},
									})
								
								
								
								
								
								
								
								
							},
							fail: (res) => {
								console.info(this_.file)
								console.log(res, '上传失败')
							}
					})
					}
					})
			},
			mtz(){
				var this_=this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function (res) {
						this_.mtrc=res.tempFilePaths[0]
						console.info(this_.mtrc)
						this_.khms.doorhead=this_.mtrc
						const baseUrl="http://localhost:8888";
						
						uni.uploadFile({
							
							url: baseUrl+'/s/business/addzidcard1/'+this_.zid,
							name: 'file',
							filePath:this_.file[0],
							header: {
								'Content-type':'multipart/form-data'
							},
							success: (uploadFileRes) => {
								// console.log(uploadFileRes)
								var a=JSON.parse(uploadFileRes.data)
								console.log(a)
							},
							})
						
						
					}
				})
			}
		}
	}
</script>

<style>
	.flex.item{
		width: 33.33%;
	}
	.bo{
		border: 1rpx solid black;
		width: 600rpx;
	}
</style>
